<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomerListWebPart.ascx.cs" Inherits="Clanta.Web.Controls.CustomerListWebPart" %>
<asp:MultiView ID="MultiView1" runat="server">
    <asp:View ID="CustomerListView" runat="server">
        <asp:GridView ID="CustomersGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" OnSelectedIndexChanged="CustomersGridView_SelectedIndexChanged" AllowSorting="True" DataSourceID="CustomerObjectDataSource" PageSize="2">
            <Columns>
                <asp:CommandField ShowSelectButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="Name" HeaderText="Navn" SortExpression="Name" />
                <asp:CommandField ShowDeleteButton="True" />
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="CustomerObjectDataSource" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="GetCustomers" SortParameterName="sortParameter" TypeName="Clanta.Web.Controls.CustomerBLL" DeleteMethod="DeleteCustomer" InsertMethod="InsertCustomer" UpdateMethod="UpdateCustomer" EnablePaging="True">
            <UpdateParameters>
                <asp:Parameter Name="id" Type="Int64" />
            </UpdateParameters>
            <SelectParameters>
                <asp:Parameter Name="sortParameter" Type="String" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String" />
            </InsertParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_Id" Type="Int64" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        
        <div style="margin-top: 10px;">
            <asp:Button ID="NewCustomerButton" runat="server" OnClick="NewCustomerButton_Click"
                Text="Ny kunde" />
        </div>
    </asp:View>
    <asp:View ID="NewCustomerView" runat="server">
        <table>
            <tr>
                <td>
                    <asp:Label ID="NameLabel" runat="server" Text="Navn" AssociatedControlID="NameTextBox" />
                </td>
                <td>
                    <asp:TextBox ID="NameTextBox" runat="server" Width="400px" MaxLength="255" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                        ErrorMessage="The name of the conference is missing"
                        ControlToValidate="NameTextBox" />
                </td>
            </tr>
        </table>

        <asp:Button ID="SaveButton" runat="server" Text="Gem" OnClick="SaveButton_Click" />
        <asp:Button ID="CancelButton" runat="server" Text="Annuller" OnClick="CancelButton_Click" />

    </asp:View>
</asp:MultiView>